/**
 * SubCharacteristicsEnum.java
 */
package co.edu.eam.iso.enums;

import java.util.ArrayList;
import java.util.List;

import co.edu.eam.iso.util.MessagesUtil;

/**
 * @author Giovanny Ramirez Blandon
 * @version 1.0
 */
public enum SubCharacteristicEnum {

	SUITABILITY           (1, 1, CharacteristicEnum.FUNCTIONALITY, "label.subcharacteristic.suitability"),
	ACCURACY              (2, 2, CharacteristicEnum.FUNCTIONALITY, "label.subcharacteristic.accuracy"),
	INTEROPERABILITY      (3, 3, CharacteristicEnum.FUNCTIONALITY, "label.subcharacteristic.interoperability"),
	SECURITY              (4, 4, CharacteristicEnum.FUNCTIONALITY, "label.subcharacteristic.security"), 
	MATURITY              (5, 1, CharacteristicEnum.RELIABILITY, "label.subcharacteristic.maturity"),
	FAULT_TOLERANCE       (6, 2, CharacteristicEnum.RELIABILITY, "label.subcharacteristic.faultTolerance"),
	RECOVERABILITY        (7, 3, CharacteristicEnum.RELIABILITY, "label.subcharacteristic.recoverability"), 
	UNDERSTANDABILITY     (8, 1, CharacteristicEnum.USABILITY, "label.subcharacteristic.understandability"),
	LEARNABILITY          (9, 2, CharacteristicEnum.USABILITY, "label.subcharacteristic.learnability"),
	OPERABILITY          (10, 3, CharacteristicEnum.USABILITY, "label.subcharacteristic.operability"),
	ATTRACTIVENESS       (11, 4, CharacteristicEnum.USABILITY, "label.subcharacteristic.attractiveness"), 
	TIME_BEHAVIOUR       (12, 1, CharacteristicEnum.EFFICIENCY, "label.subcharacteristic.timeBehaviour"),
	RESOURCE_UTILISATION (13, 2, CharacteristicEnum.EFFICIENCY, "label.subcharacteristic.resourceUtilisation"), 
	ANALYZABILITY        (14, 1, CharacteristicEnum.MAINTAINABILITY, "label.subcharacteristic.analyzability"),
	CHANGEABILITY        (15, 2, CharacteristicEnum.MAINTAINABILITY, "label.subcharacteristic.changeability"),
	STABILITY            (16, 3, CharacteristicEnum.MAINTAINABILITY, "label.subcharacteristic.stability"),
	TESTABILITY          (17, 4, CharacteristicEnum.MAINTAINABILITY, "label.subcharacteristic.testability"), 
	ADAPTABILITY         (18, 1, CharacteristicEnum.PORTABILITY, "label.subcharacteristic.adaptability"),
	INSTALLABILITY       (19, 2, CharacteristicEnum.PORTABILITY, "label.subcharacteristic.installability"),
	COEXISTENCE          (20, 3, CharacteristicEnum.PORTABILITY, "label.subcharacteristic.coexistence"),
	REPLACEABILITY       (21, 4, CharacteristicEnum.PORTABILITY, "label.subcharacteristic.replaceability");
	
	private int id;
	private int order;
	private CharacteristicEnum characteristicEnum;
	private String keyMessage;
	
	private SubCharacteristicEnum(int id, int order, 
			CharacteristicEnum characteristicEnum, String keyMessage) {
		this.id = id;
		this.order = order;
		this.characteristicEnum = characteristicEnum;
		this.keyMessage = keyMessage;
	}
	
	public static SubCharacteristicEnum getById(int id) {
		for (SubCharacteristicEnum value : SubCharacteristicEnum.values()) {
			if (id == value.getId()) {
				return value;
			}
		}
		return null;
	}
	
	public static List<SubCharacteristicEnum> getByIdCharacteristic(
			int idCharacteristic) {
		List<SubCharacteristicEnum> subCharacteristics = new ArrayList<SubCharacteristicEnum>();

		for (SubCharacteristicEnum value : SubCharacteristicEnum.values()) {
			if (idCharacteristic == value.getCharacteristicEnum().getId()) {
				subCharacteristics.add(value);
			}
		}
		return subCharacteristics;
	}
	
	public static SubCharacteristicEnum getByString(String string) {
		for (SubCharacteristicEnum subcharacteristicEnum : values()) {
			if (string.equals(subcharacteristicEnum.toString())) {
				return subcharacteristicEnum;
			}
		}
		return null;
	}	

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}
	
	/**
	 * @return the keyMessage
	 */
	public String getKeyMessage() {
		return keyMessage;
	}
	
	/**
	 * @param keyMessage the keyMessage to set
	 */
	public void setKeyMessage(String keyMessage) {
		this.keyMessage = keyMessage;
	}

	/**
	 * @return the characteristicEnum
	 */
	public CharacteristicEnum getCharacteristicEnum() {
		return characteristicEnum;
	}

	/**
	 * @param characteristicEnum the characteristicEnum to set
	 */
	public void setCharacteristicEnum(CharacteristicEnum characteristicEnum) {
		this.characteristicEnum = characteristicEnum;
	}

	/**
	 * @return the order
	 */
	public int getOrder() {
		return order;
	}

	/**
	 * @param order the order to set
	 */
	public void setOrder(int order) {
		this.order = order;
	}
	
	public String toString() {
		return MessagesUtil.getMessage(this.getKeyMessage());
	}

}
